﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LuKou.Web.UserAuth
{
    /// <summary>
    /// 用户权限认证
    /// </summary>
    public interface IMembership : IDisposable
    {
        /// <summary>
        /// 用户信息
        /// </summary>
        UserModel User { get; }
        /// <summary>
        /// 权限表
        /// </summary>
        IAuthority Authority { get; }
        /// <summary>
        /// Cookie内容
        /// </summary>
        string CookieString { get;}
        /// <summary>
        /// 读取用户信息
        /// </summary>
        void Read();
        /// <summary>
        /// 写入用户信息
        /// </summary>
        /// <param name="user"></param>
        void Write(UserModel user);
        /// <summary>
        /// 写入用户信息
        /// </summary>
        /// <param name="user">用户信息</param>
        /// <param name="expressTime">过期时间</param>
        void Write(UserModel user, DateTime expressTime);
        /// <summary>
        /// 用户退出
        /// </summary>
        void Logout();
    }

    /// <summary>
    /// 认证用户模型
    /// </summary>
    [Serializable]
    public class UserModel
    {
        /// <summary>
        /// 用户ID
        /// </summary>
        public long UID { get; set; }

        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName { get; set; }
        
        /// <summary>
        /// 用户权限代码
        /// </summary>
        //public string Code { get; set; }

        public UserModel()
        {
            UID = 0;
            UserName = string.Empty;
            //Code = new Authority().ToCode();
        }
    }
}
